package com.dididoctor.doctor.Receive;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.dididoctor.doctor.Activity.ConstantValue;
import com.dididoctor.doctor.Activity.Order.DiagnosisSuggest.DiagnosisSuggestActivity;
import com.dididoctor.doctor.Bean.Token;
import com.dididoctor.doctor.Utils.MyToast;
import com.dididoctor.doctor.Utils.SharedPreferencesUtils;
import com.dididoctor.patient.Bean.DiaeasesLitapal;

import java.util.ArrayList;
import java.util.List;

/**
 * XMPP 退出登录广播
 *
 * @author nseer
 */
public class xmppReceier extends BroadcastReceiver implements xmppView {
    private Context context;
    private List<DiaeasesLitapal> litapals = new ArrayList<>();
    private String hosId, recId, doctorId;
    private xmppPresenter presenter;

    @Override
    public void onReceive(final Context context, Intent intent) {
        this.context = context;
        presenter = new xmppPresenter(context);
        String action = intent.getAction();
        String upDataOrderStatus = SharedPreferencesUtils.getParam(Token.getMcontext(), "UpDataOrderStatus", "");
        if (ConstantValue.medicaladvice.equals(action)) {
            String msgType = intent.getStringExtra("msgType");
            switch (msgType) {
                case "medicaladvice":
                    String accId = intent.getStringExtra("accId");
                    Intent intetn = new Intent(Token.getMcontext(), DiagnosisSuggestActivity.class);
                    intetn.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intetn.putExtra("accId", accId);
                    Token.getMcontext().startActivity(intetn);

                    if (!"".equals(upDataOrderStatus) && upDataOrderStatus != null) {
                        presenter.getupdateStatus(upDataOrderStatus, "2");
                    }
                    break;
                case "Diaoprocessed":
                    if (!"".equals(upDataOrderStatus) && upDataOrderStatus != null) {
                        String upDataOrderStatus1 = intent.getStringExtra("upDataOrderStatus");
                        if (!"".equals(upDataOrderStatus1) && upDataOrderStatus1 !=null){
                            presenter.getupdateStatus(upDataOrderStatus, upDataOrderStatus1);
                        }else{
                            presenter.getupdateStatus(upDataOrderStatus, "2");
                        }

                    }
                    break;

            }

        }
    }

    @Override
    public void isOK() {

    }

    @Override
    public void isBall() {
        MyToast.DefaultmakeText(context, "结束会话失败", 0);

    }

    @Override
    public void showToastMessage(String message) {

    }

    @Override
    public void showLoadingDialog(String message) {

    }

    @Override
    public void cancelLoadingDialog() {

    }

    @Override
    public void onProgress(int bytesWritten, int totalSize) {

    }
}
